import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import pinia from './store'
import '@/utils/browserPatch'

// 权限路由
import './permission'
// svg-icons注册导入
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon/index.vue' // svg component
// UI框架 element-plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 引入阿里图标库
import '@/assets/iconfont/iconfont.css'
// import '@/assets/iconfont/iconfont.js'

// TODO 未来要删除
import '@/assets/old_iconfont/iconfont.css'
import '@/assets/old_iconfont/iconfont.js'
import '@/assets/font_order/iconfont.css'
import '@/assets/font_order/iconfont.js'

// material-icons字体图标（设计图的图标）在线编辑文本
import '@/icons/iconfont/material-icons.css'
import '@/icons/iconfont/MaterialIcons-Regular.woff2'

// font-awesome字体图标（原来第一版本的图标）https://fontawesome.com.cn/v4/icons 图标使用说明
import '@/icons/font-awesome/css/font-awesome.min.css'
import HLink from '@/components/common/link/HLink.vue'
import WatchLogin from '@/components/WatchLogin/index.vue'
import SelfDefined from '@/components/SelfDefined/index.vue'
import ShowTooltip from '@/components/ShowTooltip.vue'
import HButton from '@/components/common/button/HButton.vue'
import HPlainBgButton from './components/common/button/HPlainBgButton.vue'
import HPlainButton from '@/components/common/button/HPlainButton.vue'
import HModal from './components/common/Modal/HModal.vue'
import HDialog from './components/common/dialog/HDialog.vue'
import HImage from './components/common/image/HImage.vue'
import HDrawer from '@/components/common/drawer/HDrawer.vue'
import HStatus from './components/common/status/HStatus.vue'
import HTooltipText from '@/components/common/tooltip-text/HTooltipText.vue'
import HSpace from '@/components/common/space/HSpace.vue'
import ShowPhone from '@/components/common/show-phone/ShowPhone.vue'

// 指令
import permissionDirective from '@/utils/permissionDirective'

// 引入全局样式
import './styles/index.scss'
import './styles/common.scss'
import './styles/element.scss'
import './styles/sidebar.scss'
import './styles/transition.scss'

const app = createApp(App)
//********************全局注册 组件 */
app.component('SvgIcon', SvgIcon)
app.component('HModal', HModal) //弹窗
app.component('WatchLogin', WatchLogin)
app.component('SelfDefined', SelfDefined) //弹窗
app.component('ShowTooltip', ShowTooltip) //超出... 鼠标移动显示全部
app.component('HButton', HButton) //按钮
app.component('HPlainButton', HPlainButton) //按钮文字框
app.component('HLink', HLink) //
app.component('HDialog', HDialog)
app.component('HPlainBgButton', HPlainBgButton)
app.component('HImage', HImage)
app.component('HDrawer', HDrawer)
app.component('HStatus', HStatus)
app.component('HTooltipText', HTooltipText)
app.component('HSpace', HSpace)
app.component('ShowPhone', ShowPhone)
import * as ElIconsModules from '@element-plus/icons-vue'
// 全局注册element-plus icon图标组件
Object.keys(ElIconsModules).forEach((key) => {
  //循环遍历组件名称
  if ('Menu' !== key) {
    //如果不是图标组件不是Menu，就跳过，否则加上ICon的后缀
    app.component(key, ElIconsModules[key])
  } else {
    app.component(key + 'Icon', ElIconsModules[key])
  }
})
app.directive('permission', permissionDirective)
app.use(pinia)
app.use(router)
app.use(ElementPlus).mount('#app')
